<?php
/**
 * Model genrated using LaraAdmin
 * Help: http://laraadmin.com
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\Upload
 *
 * @property int $id
 * @property string $name
 * @property string $path
 * @property string $extension
 * @property string $caption
 * @property int $user_id
 * @property string $hash
 * @property int $public
 * @property \Carbon\Carbon|null $deleted_at
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property-read \App\User $user
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Upload onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereCaption($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereExtension($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereHash($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload wherePath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload wherePublic($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Upload whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Upload withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Upload withoutTrashed()
 * @mixin \Eloquent
 */
class Upload extends Model
{
    use SoftDeletes;
	
	protected $table = 'uploads';
	
	protected $hidden = [
        
    ];

	protected $guarded = [];

	protected $dates = ['deleted_at'];

	/**
     * Get the user that owns upload.
     */
    public function user()
    {
        return $this->belongsTo('App\User');
    }
    
    /**
     * Get File path
     */
    public function path()
    {
        return url("files/".$this->hash."/".$this->name);
    }
}
